package redisLearning;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class redisSetDemo {
    public static void main(String[] args) {
        JedisPool jedisPool = new JedisPool("tcp://127.0.0.1:8888");
        try (Jedis jedis = jedisPool.getResource()) {
            test1(jedis);
        }
    }

    private static void test1(Jedis jedis) {
        jedis.flushAll();
        jedis.sadd("key", "111", "222", "333");
        System.out.println(jedis.smembers("key"));
        System.out.println(jedis.sismember("key", "111"));
        System.out.println(jedis.sismember("key", "211"));
        System.out.println(jedis.scard("key"));
        //System.out.println(jedis.spop("key"));
        jedis.sadd("key2", "122", "222", "333", "444", "555");
        System.out.println(jedis.sinter("key", "key2"));
        System.out.println(jedis.sunion("key", "key2"));
        System.out.println(jedis.sinterstore("key3", "key", "key2"));
        System.out.println(jedis.smembers("key3"));

    }
}
